package top.lcpsky.flashcards;

import javax.servlet.MultipartConfigElement;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.MultipartConfigFactory;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.util.unit.DataSize;

import com.google.gson.Gson;

import top.lcpsky.flashcards.util.ConfigureReader;

@SpringBootApplication
@ServletComponentScan
@MapperScan(basePackages = "top.lcpsky.flashcards.mapper.**")
@EnableCaching
public class LearnToolApplication {

	public static void main(String[] args) {
		SpringApplication.run(LearnToolApplication.class, args);
	}
	@Bean
	public MultipartConfigElement multipartConfigElement() {
		final MultipartConfigFactory factory = new MultipartConfigFactory();
		factory.setMaxFileSize(DataSize.ofGigabytes(10L));
		factory.setLocation(ConfigureReader.instance().getTemporaryfilePath());
		return factory.createMultipartConfig();
	}

	@Bean
	public Gson gson() {
		return new Gson();
	}
}
